<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link th:replace="fragments/dependency :: edit-css">

<title>优铺Admin</title>
</head>

<body>
	<div class="right_col" style="background: #F7F7F7">
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_title">
						<h2>添加条件筛选</h2>

						<div class="clearfix"></div>
					</div>
					<div class="x_content">
						<br>
						<form id="demo-form2" class="form-horizontal form-label-left">
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12"> 类型 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<label class="control-label" style="margin-left: 10px;" th:each="type : ${T(com.up.upzl.biz.domain.ShopCondition.Type).values()}" th:inline="text"><input type="radio" name="type" th:value="${type}">[[${type}]] </label>
								</div>
								<span class="msg-box n-right control-label" for="type"></span>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12"> 显示文本 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="text" name="showText" required="required" class="form-control col-md-7 col-xs-12">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12"> 区间低 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="text" name="priceLow" required="required" class="form-control col-md-7 col-xs-12">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12"> 区间高 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="text" name="priceHigh" required="required" class="form-control col-md-7 col-xs-12">
								</div>
							</div>
							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12"> 排序 <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input type="text" name="sort" required="required" class="form-control col-md-7 col-xs-12">
								</div>
							</div>
							<div class="ln_solid"></div>
							<div class="form-group">
								<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
									<button class="btn btn-primary" type="reset">重置</button>
									<button type="button" id="save" class="btn btn-success">提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="fragments/dependency :: edit-js"></div>
	<script type="text/javascript">
		$('input[name="type"]').iCheck({
			radioClass : 'iradio_flat-green'
		})

		var add = {
			init : function() {
				add.initValidate();
				$("#save").on('click', function() {
					$('form').submit();
				});
			},
			initValidate : function() {
				formValidator.rules = {

				};
				formValidator.fields = {
					type : 'checked;',
					showText : 'required;',
					priceLow : 'required;integer;',
					priceHigh : 'required;integer;',
					sort : 'required',
				};
				//表单提交的实体获取函数
				formValidator.getEntity = function() {
					return {
						type : $("input[name=type]:checked").val(),
						showText : $("input[name=showText]").val(),
						priceLow : $("input[name=priceLow]").val(),
						priceHigh : $("input[name=priceHigh]").val(),
						sort : $("input[name=sort]").val(),
					};
				}
				//初始化验证路径以及回调函数
				formValidator.init('/shopCondition/add', function(data) {
					if (data.id > 0) {
						adminLayer.alert({
							content : '添加成功',
							yes : function() {
								window.parent.location.reload();
							},
							end : function() {
								
							}
						});
					}
				});
			}
		}
		add.init();
	</script>


</body>
</html>
